using System.Configuration;

namespace Rioshu.Web.ViewStateHandlers
{
    public class ViewStatePersistersConfigurationHandler : ConfigurationSection
    {
        [ConfigurationProperty("default", IsRequired = true)]
        public string DefaultPersister
        {
            get { return this["default"].ToString(); }
        }

        [ConfigurationProperty("persisters", IsRequired = true)]
        public NameTypeElementCollection Persisters
        {
            get { return this["persisters"] as NameTypeElementCollection; }
        }

        public static ViewStatePersistersConfigurationHandler GetConfiguration()
        {
            return ConfigurationManager.GetSection("viewStateHandlers/viewStatePersisters") as ViewStatePersistersConfigurationHandler;
        }

        public string DefaultPersisterType
        {
            get { return Persisters[DefaultPersister].Type; }
        }
    }
}